﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CurriCulumnTeacherManage.aspx.cs"
    Inherits="WebCurriculumn.CurriCulumnTeacherManage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>教員指定</title>
    <link href="Styles/site.css" rel="stylesheet" type="text/css" />

    <script src="Script/jquery-1.4.1.min.js" type="text/javascript"></script>

    <style type="text/css">
        .test
        {
            width: 30px;
            visibility: hidden;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <%--            <asp:Label ID="Label1" runat="server" Text="授業内容:"></asp:Label><asp:Literal ID="ltrContent"
                runat="server"></asp:Literal></div>--%>
                <div id="divNewAdd" style="margin-left: 50px; margin-top: 20px">
            <asp:Label ID="Label2" runat="server" Text="教員所属"></asp:Label>
            <asp:DropDownList ID="ddlTeacherDepartment" runat="server" CssClass="select" AutoPostBack="true" Font-Size="10.5px"
                OnSelectedIndexChanged="ddlTeacherDepartment_SelectedIndexChanged">
            </asp:DropDownList>
            <asp:Label ID="Label3" runat="server" Text="教員"></asp:Label>
            <asp:DropDownList ID="ddlTeacher" runat="server" CssClass="select" Width="200px">
            </asp:DropDownList>
            <br />
            <asp:Button ID="btnSave" runat="server" Text="追加" CssClass="button" OnClick="btnSave_Click"
                />
            <input id="btnCancel" type="button" value="キャンセル" class="button"  />
            <asp:Button ID="btnDeleteTeacher" runat="server" Text="削除教員" CssClass="button" 
                OnClick="btnDeleteTeacher_Click" OnClientClick="deleteTeacher()" />
        </div>
        
        <div style="margin-left: 50px; margin-top: 10px">
            <table cellspacing="0" rules="all" border="1" style="border-collapse: collapse;">
                <tr>
                    <td width="72" align="center">
                        選択
                    </td>
                    <td width="250" align="center">
                        教員名称
                    </td>
                    <td width="150" align="center">
                        教員所属
                    </td>
                </tr>
            </table>
        </div>
        <div id="divContent" style="height: 200px; overflow-y: auto; width: 533px">
            <asp:GridView ID="gvTeacher" runat="server" AutoGenerateColumns="False" ShowHeader="true"
                DataKeyNames="" Style="margin-left: 50px;" EmptyDataText="教員がない" EmptyDataRowStyle-Font-Bold="true"
                EmptyDataRowStyle-Font-Size="Larger" EmptyDataRowStyle-ForeColor="Green" EmptyDataRowStyle-BorderWidth="0"
                OnRowDataBound="gvTeacher_RowDataBound" HeaderStyle-CssClass="noHeader">
                <Columns>
                    <asp:TemplateField HeaderText="選択" HeaderStyle-Width="70px">
                        <ItemTemplate>
                            <asp:CheckBox runat="server" ID="chkID" name="checkbox"></asp:CheckBox>
                            <asp:Label ID="lblMapId" runat="server" Text='<%#Bind("iMapTeacherDepartmentId") %>'
                                CssClass="test"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="iLectureTeacherId" HeaderText="ID" HeaderStyle-Width="60px"
                        Visible="false" ItemStyle-HorizontalAlign="Center">
                        <HeaderStyle Width="60px"></HeaderStyle>
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="教員名称" HeaderStyle-Width="300px" ItemStyle-HorizontalAlign="Left">
                        <ItemTemplate>
                            <asp:Label ID="lblTeacherName" runat="server" Text='<%#Bind("vTeacherName") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="教員所属" HeaderStyle-Width="150px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Label ID="lblDepartment" runat="server" Text='<%#Bind("vTeacherDepartmentName") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="iMapTeacherDepartmentId" Visible="false"></asp:BoundField>
                </Columns>
                <%--            <EmptyDataTemplate>
                <table border="1">
                    <tr>
                        <td>
                            選択
                        </td>
                        <td>
                            教員ID
                        </td>
                        <td>
                            教員名称
                        </td>
                        <td>
                            教員所属
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            教員がない
                        </td>
                    </tr>
                </table>
            </EmptyDataTemplate>--%>
            </asp:GridView>
        </div>
        <%--        <div id="divButton" style="margin-left: 50px; margin-top: 20px">
            <input id="btnAddTeacher" type="button" value="追加教員" class="button" style=" font-size:16px" />

        </div>--%>
        
    </div>
    <asp:HiddenField ID="hfMapId" runat="server" />
    </form>
</body>

<script type="text/javascript">
    $(document).ready(function() {
        //        if ('<%=ViewState["keepAdd"] %>' != 'true') {
        //            $("#divNewAdd").css("display", "none");
        //        } $("#btnAddTeacher").click(function() {
        //            $("#divNewAdd").css("display", "block");
        //        });
        //        $("#btnCancel").click(function() {
        //            $("#divNewAdd").css("display", "none");
        //        });
        //        if ('<%=editMode %>' != 'True') {
        //            $("#btnAddTeacher").css("display", "none");
        //        }
    });
    function deleteTeacher() {
        var checkedCount = 0;
        var mapIdList = "";
        $("[type=checkbox]:checkbox").each(function(index) {
            if ($(this).attr("checked") == true) {
                checkedCount++;
                mapIdList += $(".test:eq(" + index + ")").html() + ","
            }
        });
        if (checkedCount < 1) {
            alert("教員を選択してください");
            event.returnValue = false;
        }
        if (mapIdList != "") {
            $("#hfMapId").val(mapIdList.substr(0, mapIdList.length - 1));
        } else {
            event.returnValue = false;
        }
    }
</script>

</html>
